bitkeeper revision 1.418.1.1 (3f5f3d862n2oSqg-bvcUtq4TeyrP1g)
authortlh20@labyrinth.cl.cam.ac.uk <tlh20@labyrinth.cl.cam.ac.uk>
Wed, 10 Sep 2003 15:04:38 +0000 (15:04 +0000)
committertlh20@labyrinth.cl.cam.ac.uk <tlh20@labyrinth.cl.cam.ac.uk>
Wed, 10 Sep 2003 15:04:38 +0000 (15:04 +0000)
Many files:
  Attempt at new xenctl

12 files changed:
tools/control/src/org/xenoserver/cmdline/Main.java
tools/control/src/org/xenoserver/cmdline/ParseDomainDestroy.java
tools/control/src/org/xenoserver/cmdline/ParseDomainStart.java
tools/control/src/org/xenoserver/cmdline/ParseDomainStop.java
tools/control/src/org/xenoserver/cmdline/ParsePhysicalGrant.java
tools/control/src/org/xenoserver/cmdline/ParsePhysicalList.java
tools/control/src/org/xenoserver/cmdline/ParsePhysicalRevoke.java
tools/control/src/org/xenoserver/cmdline/ParseVbdCreate.java
tools/control/src/org/xenoserver/control/CommandDomainNew.java
tools/control/src/org/xenoserver/control/Defaults.java
tools/control/src/org/xenoserver/control/Settings.java
tools/control/xenctl

index 3b8cc554b7873b6e3b229e8bfaec10ca3354887e..fe7c6a2c258ecf935604c2279ca88ce8dfc75b96 100644 (file)
@@ -43,12 +43,23 @@ public class Main {
       new ParseGroup( "domain", domaincommands ),
       new ParseGroup( "partitions", partitioncommands ),
       new ParseGroup( "physical", physicalcommands ),
+      new ParseScript(),
       new ParseGroup( "vd", vdcommands ),
       new ParseGroup( "vbd", vbdcommands )
     };
   /** The top-level parser. */
   static final CommandParser parser = new ParseGroup( null, commands );
 
+  public static void executeArgList (Defaults d, LinkedList arglist)
+     throws ParseFailedException, CommandFailedException 
+  {
+    if (arglist.size() == 0) {
+      help.parse(null, null);
+    } else {
+      parser.parse(d, arglist);
+    }
+  }
+
   public static void main(String[] args) {
     Defaults d = new Defaults();
     int ec = -1;
@@ -57,20 +68,15 @@ public class Main {
       arglist.add( args[i] );
     }
 
-    if (args.length == 0) {
+    try {
+      executeArgList (d, arglist);
+      ec = 0;
+    } catch (NoSuchElementException e) {
       help.parse(null, null);
-    } else {
-      try
-      {
-        parser.parse(d, arglist);
-        ec = 0;
-      } catch (NoSuchElementException e) {
-          help.parse(null, null);
-      } catch (ParseFailedException e) {
-        System.err.println( e.getMessage() );
-      } catch (CommandFailedException e) {
-        System.err.println( e.getMessage() );
-      }
+    } catch (ParseFailedException e) {
+      System.err.println( e.getMessage() );
+    } catch (CommandFailedException e) {
+      System.err.println( e.getMessage() );
     }
 
     System.exit(ec);
index 78d224cf5e6a4e5d302f58ae168816de3204748d..d556275ecb37474d86879c412a48c2dd6a886c2d 100644 (file)
@@ -9,7 +9,7 @@ import org.xenoserver.control.Defaults;
 public class ParseDomainDestroy extends CommandParser {
     public void parse(Defaults d, LinkedList args)
         throws ParseFailedException, CommandFailedException {
-        int domain_id = getIntParameter(args, 'n', 0);
+        int domain_id = getIntParameter(args, 'n', d.domainNumber);
         boolean force = getFlagParameter(args, 'f');
 
         if (domain_id == 0) {
@@ -27,7 +27,7 @@ public class ParseDomainDestroy extends CommandParser {
     }
 
     public String getUsage() {
-        return "-n<domain_id> [-f]";
+        return "[-n<domain_id>] [-f]";
     }
 
     public String getHelpText() {
index e27394cb23f0f0e163ef2c1670f2fc3de771f6b2..4b676f568b43eba9ffaba8e04ecb3b1f56a2427e 100644 (file)
@@ -9,7 +9,7 @@ import org.xenoserver.control.Defaults;
 public class ParseDomainStart extends CommandParser {
     public void parse(Defaults d, LinkedList args)
         throws ParseFailedException, CommandFailedException {
-        int domain_id = getIntParameter(args, 'n', 0);
+        int domain_id = getIntParameter(args, 'n', d.domainNumber);
 
         if (domain_id == 0) {
             throw new ParseFailedException("Expected -n<domain_id>");
@@ -25,7 +25,7 @@ public class ParseDomainStart extends CommandParser {
     }
 
     public String getUsage() {
-        return "-n<domain_id>";
+        return "[-n<domain_id>]";
     }
 
     public String getHelpText() {
index 306f18529b7f719c6aaac8ba0129a2bf75fefd7e..e4727b33e37e4c783c3f82143ebd0b4c9b40a61c 100644 (file)
@@ -9,7 +9,7 @@ import org.xenoserver.control.Defaults;
 public class ParseDomainStop extends CommandParser {
     public void parse(Defaults d, LinkedList args)
         throws ParseFailedException, CommandFailedException {
-        int domain_id = getIntParameter(args, 'n', 0);
+        int domain_id = getIntParameter(args, 'n', d.domainNumber);
 
         if (domain_id == 0) {
             throw new ParseFailedException("Expected -n<domain_id>");
@@ -25,7 +25,7 @@ public class ParseDomainStop extends CommandParser {
     }
 
     public String getUsage() {
-        return "-n<domain_id>";
+        return "[-n<domain_id>]";
     }
 
     public String getHelpText() {
index f332d5c698b7931d7c7299b72da0b326f34f2bb9..521d2e740aa3fdd8ee67fbf0dce0cae333ea7ef8 100644 (file)
@@ -10,7 +10,7 @@ import org.xenoserver.control.Mode;
 public class ParsePhysicalGrant extends CommandParser {
     public void parse(Defaults d, LinkedList args)
         throws ParseFailedException, CommandFailedException {
-        int domain_id = getIntParameter(args, 'n', 0);
+        int domain_id = getIntParameter(args, 'n', d.domainNumber);
         boolean force = getFlagParameter(args, 'f');
         String partition_name = getStringParameter(args, 'p', "");
         boolean write = getFlagParameter(args, 'w');
@@ -44,7 +44,7 @@ public class ParsePhysicalGrant extends CommandParser {
     }
 
     public String getUsage() {
-        return "-n<domain_id> -p<partition_name> [-f] [-w]";
+        return "-p<partition_name> [-n<domain_id>] [-f] [-w]";
     }
 
     public String getHelpText() {
index 1b662aa06976d1ddb059516434f86ed3d53b8820..85e6e5de1912f145d6f9ce41af898c1c18525986 100644 (file)
@@ -15,7 +15,7 @@ import org.xenoserver.control.PartitionManager;
 public class ParsePhysicalList extends CommandParser {
     public void parse(Defaults d, LinkedList args)
         throws ParseFailedException, CommandFailedException {
-        int domain_id = getIntParameter(args, 'n', 0);
+        int domain_id = getIntParameter(args, 'n', d.domainNumber);
         if (domain_id == 0) {
             throw new ParseFailedException("Expected -n<domain_id>");
         }
index 56d37e6dace2d603854cbdfe7f228b644bf0fb15..e53a16ab39f9c2663267a5914eecf84ea23c3844 100644 (file)
@@ -9,7 +9,7 @@ import org.xenoserver.control.Defaults;
 public class ParsePhysicalRevoke extends CommandParser {
     public void parse(Defaults d, LinkedList args)
         throws ParseFailedException, CommandFailedException {
-        int domain_id = getIntParameter(args, 'n', 0);
+        int domain_id = getIntParameter(args, 'n', d.domainNumber);
         String partition_name = getStringParameter(args, 'p', "");
 
         if (domain_id == 0) {
@@ -32,7 +32,7 @@ public class ParsePhysicalRevoke extends CommandParser {
     }
 
     public String getUsage() {
-        return "-n<domain_id> -p<partition_name>";
+        return "-p<partition_name> [-n<domain_id>]";
     }
 
     public String getHelpText() {
index 54713b45fc3c6b0dc2b1a9cc238f55958dd18fc4..cacb9878162c33181ace11ab3b43e7fed57d28bc 100644 (file)
@@ -13,7 +13,7 @@ public class ParseVbdCreate extends CommandParser {
         throws ParseFailedException, CommandFailedException {
         String vd_key = getStringParameter(args, 'k', "");
         String partition_name = getStringParameter(args, 'p', "");
-        int domain_id = getIntParameter(args, 'n', 0);
+        int domain_id = getIntParameter(args, 'n', d.domainNumber);
         int vbd_num = getIntParameter(args, 'v', -1);
         boolean write = getFlagParameter(args, 'w');
 
@@ -53,7 +53,7 @@ public class ParseVbdCreate extends CommandParser {
     }
 
     public String getUsage() {
-        return "-n<domain_id> {-k<key>|-p<partition} -v<vbd_num> [-w]";
+        return "{-k<key>|-p<partition} -v<vbd_num> [-n<domain_id>] [-w]";
     }
 
     public String getHelpText() {
index 5600cd04daf852bb7273913574b0c30be5542dce..b8341551d17b11eed6a417b5523fcc8473cf5b32 100644 (file)
@@ -185,6 +185,7 @@ public class CommandDomainNew extends Command {
                     domain_id = Integer.parseInt(br.readLine());
                     create_rc = create_p.waitFor();
                 }
+               d.domainNumber = domain_id;
 
                 if (create_rc != 0) {
                     throw CommandFailedException.xiCommandFailed(
index d180a3eb917697ad43a420175262cd3ea4fd8f32..e64f6e19d16160603c2853cb24723604b7f5d61a 100644 (file)
@@ -49,6 +49,8 @@ public class Defaults {
     public String args = "";
     /** Directory to find XI tools. */
     public String xiToolsDir = "";
+    /** Domain number */
+    public int domainNumber;
 
     
     /**
@@ -143,6 +145,8 @@ public class Defaults {
                     domainImage = s;
                 } else if (lastName.equals("domain_name")) {
                     domainName = s;
+                } else if (lastName.equals("domain_number")) {
+                    domainNumber = Integer.parseInt(s);
                 } else if (lastName.equals("domain_init_rd")) {
                     domainInitRD = s;
                 } else if (lastName.equals("domain_vifs")) {
index 02cdbdecd6ae716d20fe74adc07e3c7dbf0853cb..317bdb1c779e0ca29e514422f67899e8c870ec1e 100644 (file)
@@ -14,12 +14,6 @@ public final class Settings {
     /** Path to search for the defaults file. */
     public static final String DEFAULTS_PATH =
         System.getProperty("DEFAULTS_PATH", ".:/etc:/var/lib/xen");
-    /** IP address of domain 0. */
-    public static final String LOCAL_IP = System.getProperty("LOCAL_IP");
-    /** Network mask of domain 0. */
-    public static final String LOCAL_MASK = System.getProperty("LOCAL_MASK");
-    /** Gateway of domain 0. */
-    public static final String LOCAL_GW = System.getProperty("LOCAL_ROUTE");
     /** If set, do not call any xi_ commands, just print their command lines. */
     public static final boolean TEST = (System.getProperty("TEST") != null);
     /** Name of xi_helper utility. */
index 9b30b81617f4e73400665018d1c02df8551d75c5..d653d7d8a4849dd6676c2f1a20c93ca1e7be66b3 100755 (executable)
@@ -7,27 +7,7 @@ if [ -z "$IFCONFIG" ] ; then IFCONFIG=/sbin/ifconfig ; fi
 if [ -z "$ROUTE" ] ; then ROUTE=/sbin/route ; fi
 if [ -z "$JAVA" ] ; then JAVA=java ; fi
 
-if [ "$1" = "domain" -a "$2" = "new" ] ; then
-  if [ ! -x "$IFCONFIG" ]; then  
-    echo Could not find executable $IFCONFIG
-    exit 1
-  fi
-
-  if [ ! -x "$ROUTE" ]; then
-    echo Could not find executable $ROUTE
-    exit 1
-  fi
-
-  # Try to determine dom0 network settings to avoid hard-coding
-  # particular machines in the defaults file
-  LOCAL_IP=$(/sbin/ifconfig $QUERY_DEV | grep 'inet addr' | tr ':' '\t' | awk '{print $3}')
-  LOCAL_MASK=$(/sbin/ifconfig $QUERY_DEV | grep 'Mask' | tr ':' '\t' | awk '{print $7}')
-  LOCAL_ROUTE=$(/sbin/route -n | grep $QUERY_DEV | grep 'G' | awk '{print $2}')
-fi
-
-
-#ARGS="-DTEST -DDEFAULTS_FILE=$DEFAULTS_FILE -DDEFAULTS_PATH=$DEFAULTS_PATH -DLOCAL_IP=$LOCAL_IP -DLOCAL_MASK=$LOCAL_MASK -DLOCAL_ROUTE=$LOCAL_ROUTE"
-ARGS="-DDEFAULTS_FILE=$DEFAULTS_FILE -DDEFAULTS_PATH=$DEFAULTS_PATH -DLOCAL_IP=$LOCAL_IP -DLOCAL_MASK=$LOCAL_MASK -DLOCAL_ROUTE=$LOCAL_ROUTE"
 
+ARGS="-DDEFAULTS_FILE=$DEFAULTS_FILE -DDEFAULTS_PATH=$DEFAULTS_PATH"
 
 $JAVA $ARGS -jar $(dirname $0)/xenctl-cmdline.jar $*